angular.module('myapp',['ngRoute','angularCSS','home','origin','freshfruit','market','food','xqing','search','login','signin'])
.config(['$routeProvider','$locationProvider',function($routeProvider,$locationProvider){
	$locationProvider.html5Mode(false).hashPrefix('');
	$routeProvider.otherwise({redirectTo:'/home'});
}])
.controller('allCtrl',function($scope,$rootScope,$window,$http){
	//欢迎***登录
	$scope.sb=localStorage.sb;
	$scope.tc = function(){
		localStorage.removeItem('sb');
		location.reload();
	}
	
	//向上按钮
	$scope.top = function(){
		document.body.scrollTop = 0;
	}
	//头部和底部显示隐藏
	$rootScope.sh = true;
	
	//左侧二级导航
	$rootScope.List1 = ['天宁','武进','钟楼','新北','溧阳','金坛'];
	$rootScope.List2 = ['苹果类','梨类','柑橘类','瓜类','浆果类','热带水果类','其他水果'];
	$rootScope.List3 = ['苹果类','梨类','柑橘类','浆果类','热带水果','其他进口水果','瓜类'];
	$rootScope.List4 = ['国产水果礼盒','进口水果礼盒'];
	$rootScope.List5 = ['菌菇类','白菜类','绿叶菜类','根菜类','葱蒜类','茄果类','瓜类','豆类','薯芋类','水生蔬菜'];
	$rootScope.List6 = ['菌菇类','白菜类','叶菜类','根茎类','葱蒜类','茄果类','瓜类','豆类','薯芋类','水生蔬菜'];
	$rootScope.List7 = ['蔬菜沙拉','加工净菜','冷冻蔬果'];
	$rootScope.List8 = ['豆腐','豆腐干','腐皮腐竹'];
	$rootScope.List9 = ['活杀家禽','冷鲜禽肉'];
	$rootScope.List10 = ['牛肉','羊肉','猪肉'];
	$rootScope.List11 = ['腌制品','卤制品'];
	$rootScope.List12 = ['新鲜蛋类','皮蛋咸蛋卤蛋'];
	$rootScope.List13 = ['新鲜蛋类','皮蛋咸蛋卤蛋'];
	$rootScope.List14 = ['大米','面粉面条','杂粮'];
	$rootScope.List15 = ['南北干货','海鲜干货'];
	$rootScope.List16 = ['调和油','花生油','菜籽油','玉米油','葵花籽油','橄榄油','特种油'];
	$rootScope.List17 = ['调味料','调味酱果酱','酱菜腐乳','调味油料酒'];
	$rootScope.List18 = ['常温纯牛奶','常温酸奶','低温奶','豆奶','儿童乳品','奶粉','含乳饮料'];
	$rootScope.List19 = ['饮用水','碳酸饮料','功能饮料','茶饮料','果汁饮料','咖啡奶茶','蜂蜜饮品','冲调饮品'];
	$rootScope.List20 = ['白酒','啤酒','黄酒保健酒','葡萄酒','鸡尾酒','其他酒'];
	$rootScope.List21 = ['方便面','方便粉丝','速食米饭'];
	$rootScope.List22 = ['坚果炒货','肉铺蜜饯','海味即食'];
	$rootScope.List23 = ['膨化食品','饼干糕点'];
	$rootScope.List24 = ['口香糖','糖果','巧克力','果冻布丁'];
	$rootScope.List25 = ['水饺蒸饺','馄饨','汤圆','包子馒头','火锅食材','速冻面食','奶酪芝士黄油'];
	$rootScope.List26 = ['冷冻禽肉','冷冻牛羊肉 ','牛排披萨'];
	$rootScope.List27 = ['冷冻海鲜','江鲜水产'];
	$rootScope.List28 = ['制品湿巾','衣物清洁','居室清洁','清洁用具','餐具厨具','一次性用品'];
	$rootScope.List29 = ['美发护发','女性护理','男士护理','面部护理','口腔护理','身体护理','洗浴用品'];
	$rootScope.List30 = ['床上用品','针织品','收纳洗晒','居家日用'];
	$rootScope.List31 = ['吉米厨房','楼口生鲜','楼口网上菜场','蔡氏鸡蛋','大麦鲜食','产地预售'];
	
	//搜索的下拉框
	$scope.xl = false;
	$scope.focus = function(){
		$scope.xl = true;
	}
	$scope.blur = function(){
		$scope.xl = false;
	}
	$rootScope.arr2 = [];
	
	
	//搜索框
	$scope.data = "";
//	//判断是否有本地存储
	if(!$window.localStorage.search){
		$window.localStorage.search="[]";
	}
	//清空历史记录
	$scope.removedata = function(){
		$scope.searchdata=[];
		$window.localStorage.search="[]";
	}
	//是否已经搜索
	$scope.bol = true;
	//获取本地存储
	$scope.searchdata = JSON.parse($window.localStorage.search);
	$http.get('http://www.yanhanbo.top/user/origin.php?names=&imgs=&standard=&genre=&delivery=&price=&type=%E6%89%80%E6%9C%89').then(function(data){
		$rootScope.kk = data.data.data;
		
	})
	
	$rootScope.Sarr = [];
	$scope.tz = "#/search";
	$scope.dat = function(){
		//判断输入框中是否有数据
		if($scope.data!=""){
			$scope.tz = "#/search";
			$scope.searchdata.push($scope.data)
			$window.localStorage.search=JSON.stringify($scope.searchdata);
			$scope.bol = false;
			$scope.data1=$scope.data;
		}else{
			$scope.tz = "";
			alert('搜索内容不能为空!');
		}
		$scope.xl = false;
		for(var i=0;i<$rootScope.kk.length;i++){
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.jc = function(){
		$rootScope.Sarr = [];
		$scope.data = '加工净菜';
		for(var i=0;i<$rootScope.kk.length;i++){
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.jc1 = function(){
		$rootScope.Sarr = [];
		$scope.data = '糖果';
		for(var i=0;i<$rootScope.kk.length;i++){
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.jc2 = function(){
		$rootScope.Sarr = [];
		$scope.data = '坚果炒货';
		for(var i=0;i<$rootScope.kk.length;i++){
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.jc3 = function(){
		$rootScope.Sarr = [];
		$scope.data = '其他进口水果';
		for(var i=0;i<$rootScope.kk.length;i++){
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.jc4 = function(){
		$rootScope.Sarr = [];
		$scope.data = '洗浴用品';
		for(var i=0;i<$rootScope.kk.length;i++){
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.jc5 = function(){
		$rootScope.Sarr = [];
		$scope.data = '美发护发';
		for(var i=0;i<$rootScope.kk.length;i++){
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.jc6 = function(){
		$rootScope.Sarr = [];
		$scope.data = '牙膏';
		for(var i=0;i<$rootScope.kk.length;i++){
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.jc7 = function(){
		$rootScope.Sarr = [];
		$scope.data = '调味料';
		for(var i=0;i<$rootScope.kk.length;i++){
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	//左侧二级导航
	$scope.listclick1 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List1[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick2 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List2[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick3 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List3[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick4 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List4[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick5 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List5[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick6 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List6[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick7 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List7[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick8 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List8[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick9 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List9[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick10 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List10[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	
	$scope.listclick11 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List11[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick12 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List12[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick13 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List13[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick14 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List14[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick15 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List15[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick16 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List16[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick17 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List17[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick18 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List18[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick19 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List19[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick20 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List20[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick21 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List21[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick22 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List22[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick23 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List23[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick24 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List24[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick25 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List25[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick26 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List26[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick27 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List27[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick28 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List28[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick29 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List29[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick30 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List30[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	$scope.listclick31 = function(index){
		$rootScope.Sarr = [];
		for(var i=0;i<$rootScope.kk.length;i++){
			$scope.data = $rootScope.List31[index];
			if($scope.data == $rootScope.kk[i]['genre']){
				$rootScope.Sarr.push($rootScope.kk[i]);
			}
		}
	}
	//右侧导航栏二维码显示隐藏
	$('.aaa').click(function(){
		$('.img2').toggle();
	})
	$('#gw').click(function(){
		$('.shopping').toggle();
	})
	$('.tit span').click(function(){
		$('.shopping').hide();
	})
	//购物车
	$http.get('http://www.yanhanbo.top/user/gwc.php?names=&imgs=&standard=&genre=&delivery=&price=&type=%E6%89%80%E6%9C%89').then(function(data){
		//购物车数据
		$rootScope.gwcd = data.data.data;
		//购物车总价
		$scope.total = function(){
			var num = 0;
			for(var i =0;i<$rootScope.gwcd.length;i++){
				num+=$rootScope.gwcd[i]['price']*$rootScope.gwcd[i]['num'];
			}
			return num;
		}
		//商品数量
		$scope.nums = function(){
			var n = 0;
			for(var i=0;i<$rootScope.gwcd.length;i++){
				n+=parseInt($rootScope.gwcd[i]['num']);
			}
			return n;
		}
		//删除一个商品
		$scope.delete = function(index){
			return $rootScope.gwcd.splice(index,1);
		}
		//减
		$scope.remove = function(index){
			if($rootScope.gwcd[index]['num']==1){
				if(confirm('是否删除此商品?')){
					$rootScope.gwcd.splice(index,1);
				}
			}else{
				$rootScope.gwcd[index]['num'] --;
			}
		}
		//加
		$scope.add = function(obj){
			return obj['num']++;
		}
		//结算
		$scope.js = function(){
			alert('购买成功!');
			$rootScope.gwcd = [];
		}
	})
	//右侧会员登录
	$scope.hy = function(){
		if(localStorage.sb){
			alert('会员中心正在维护！敬请期待~');
		}else{
			alert('您尚未登录!');
			window.location.href="http://127.0.0.1:8020/pcduantao/Taocz%20PC/src/index.html#/login";
		}
	}
})